<template>
  <div class="detail">
    <div class="detail-head">推荐歌单</div>
    <!-- 中间的歌单 -->
    <div class="detail-list">
      <ul class="detail-list-ul">
        <li
          class="detail-list-item"
          v-for="song in songList"
          :key="song.dissid"
        >
          <div class="item-box">
            <div class="box-cover">
              <router-link :to="`/playlist/${song.dissid}`">
                <i class="box-mask"></i>
                <img
                  class="box-img"
                  load="lazying"
                  :src="song.imgurl"
                  :alt="song.dissname"
                />
              </router-link>
            </div>
            <div class="box-h4">
              <span class="box-span">
                <router-link class="box-h4-a" to="/playlist">{{
                  song.dissname
                }}</router-link>
              </span>
            </div>
            <div class="author">
              <a href="#" class="author-name">{{ song.creator.name }}</a>
            </div>
            <div class="other">播放量:{{ song.listennum }}</div>
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>

<script lang="ts">
export default {
  name: 'RecommendPlaylist',
}
</script>

<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import { getSongListsApi } from '@/api/category/getSongLists'
import { useRouter } from 'vue-router'
import type { SongList } from '@/api/category/model/getSongListsModel'
const emit = defineEmits(['setShowPlayList'])
// const router = useRouter()
// const goPlayList = () => {
//   router.push({
//     name: 'PlayList',
//   })
// }
const songList = ref<SongList>([])

// 封装获取歌单列表的函数
const getSongList = async (id: number) => {
  const res = await getSongListsApi(id)
  songList.value = res.data.list
  console.log(res)
  console.log(songList.value)
}
onMounted(() => {
  getSongList(10000000)
})
</script>

<style scoped>
.detail {
  margin-bottom: 10px;
}
.detail-head {
  height: 40px;
  float: left;
  font-size: 24px;
  font-weight: 400;
  line-height: 58px;
  width: 1200px;
}

.detail-list-ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.detail-list-item {
  list-style-type: none;
  display: inline-block;
  width: 20%;
  padding-bottom: 40px;
  overflow: hidden;
  font-size: 14px;
  vertical-align: top;
}
.item-box {
  margin-right: 20px;
}
.box-cover {
  overflow: hidden;
  padding-top: 10px;
  margin-bottom: 8px;
  position: relative;
}

.box-img {
  height: 224px;
  width: 224px;
}
.box-mask {
  position: absolute;
  width: 224px;
  height: 224px;
  background-color: rgba(0, 0, 0, 0.2);
  transition: 0.3s;
  background-image: url('../../imgs/cover_play.56974e6f.png');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 70px 70px;
  opacity: 0;
  z-index: 999;
  cursor: pointer;
}
.box-mask:hover {
  opacity: 1;
  background-size: 80px 80px;
}
.box-mask:hover + img {
  transform: scale(1.01);
}

.box-h4 {
  overflow: hidden;
}
.box-span {
  float: left;
  max-width: 100%;
  font-weight: 400;
  text-overflow: ellipsis;
  line-height: 22px;
  max-height: 44px;
}
.box-h4-a {
  height: 22px;
}
a {
  color: #000;
  cursor: pointer;
  text-decoration: none;
}
a:hover {
  color: rgb(49, 194, 124);
  text-decoration: none;
}
.author,
.author-name,
.other {
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 22px;
  font-size: 14px;
  text-decoration: none;
}
</style>
